﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;

namespace XML
{
    class XMLWriter
    {
        public bool SerializeMap(Map map,string mapName)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Map));
                StringWriter stw = new StringWriter();
                XmlWriter writer = XmlWriter.Create(stw);
                StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + "\\" + mapName);

                serializer.Serialize(stw, map);

                sw.WriteLine(stw.ToString());
                sw.Flush();
                sw.Close();

                return true;
            }
            catch(Exception)
            {
                return false;
            }
        }
    }
}
